package org.rslai.tcedit.domain;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.OrderBy;
import org.hibernate.validator.Length;

/**
 * 产品信息
 * 
 * @author rslai
 */
@Entity
@Table(name="t_product")
public class Product extends UUIDSupport {

	private String name; // 产品名 
	private String describing; // 产品描述
	private boolean locked = false; // 次产品是否锁定
	private Set<Version> versions = new HashSet<Version>(0); // 版本

	@Column(nullable = false, length = 50)
	@Length(max = 50, message = "产品名请限制在50字以内")
	public String getName() { return name; }
	public void setName(String name) { this.name = name; }

	@Column(nullable = true, length = 100)
	@Length(max = 100, message = "产品描述请限制在100字以内")
	public String getDescribing() { return describing; }
	public void setDescribing(String describing) { this.describing = describing; }

	@Column(nullable = false)
	public Boolean getLocked() { return locked; }
	public void setLocked(Boolean locked) { this.locked = locked; }

	@OneToMany
	@OrderBy(value="name")
	public Set<Version> getVersions() { return versions; }
	public void setVersions(Set<Version> versions) { this.versions = versions; }

//		INSERT INTO [dbo].[Product]
//			(UID, ProductName, ProductDescribing, TableIdentifier, Locked)
//		    VALUES ('2007022313264471fc32', 'TestProduct', '测试产品', '', 0)
//		GO

}
